﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        BieumauDataContext _db = new BieumauDataContext();
        var list = _db.tblBieuMaus.ToList();
        int cout = 0;
        foreach (var item in list)
        {
            if (Update(item.MaDonVi, item.TenBieuMau, item.DuLieu.Replace(",", "~")))
            {
                cout++;
            }
        }
        Response.Write("sdf sdf df = "+cout.ToString());
    }

    protected bool Update(string ma1,string ma2,string st)
    {
        BieumauDataContext _db = new BieumauDataContext();
        var item = _db.tblBieuMaus.Single(r => r.MaDonVi.Trim() == ma1.Trim() && r.TenBieuMau.Trim() == ma2.Trim());
        item.DuLieu = st;
        try
        {
            _db.SubmitChanges();
            return true;
        }
        catch { return false; }
    }
}